Option Explicit
Sub H_Sample002()
    'ոH_Data01
    Dim myCht    As Chart
    Dim myChtobj As ChartObject
    Dim mySht1   As Worksheet
    Dim mySht2   As Worksheet
    Dim myRng1   As Range
    Dim myRng2   As Range
    Dim myRng3   As Range
    'w¦
    Set mySht1 = Worksheets("H_Data01")
    Set mySht2 = Worksheets.Add
    Set myRng1 = mySht1.Range("D2:D21")         'ƽd
    Set myRng2 = mySht1.Range("E2:E21")
    Set myRng3 = mySht1.Range("D1:E1")
    For Each myChtobj In mySht2.ChartObjects
        myChtobj.Delete
    Next
    Set myCht = Charts.Add
    With myCht
        .ChartType = xlXYScatter
        .SetSourceData Source:=mySht1.Range("A1"), PlotBy:=xlRows
        .SeriesCollection(1).XValues = myRng1
        .SeriesCollection(1).Values = myRng2
        .Location Where:=xlLocationAsObject, Name:=mySht2.Name
    End With
    Set myCht = mySht2.ChartObjects(mySht2.ChartObjects.Count).Chart
    With mySht2.Shapes(mySht2.Shapes.Count)
        .Top = 10
        .Left = 10
        .Width = 300
        .Height = 300
    End With
    With myCht
        .HasLegend = False
        .HasTitle = True
        .ChartTitle.Characters.Text = _
        myRng3.Cells(1).Value & "-" & myRng3.Cells(2).Value
        With .Axes(xlCategory, xlPrimary)
            .HasTitle = True
            .AxisTitle.Characters.Text = myRng3.Cells(1).Value
        End With
        With .Axes(xlValue, xlPrimary)
            .HasTitle = True
            .AxisTitle.Characters.Text = myRng3.Cells(2).Value
            .AxisTitle.Orientation = xlHorizontal
        End With
        With .PlotArea
            .Left = 20
            .Top = 20
            .Width = 250
            .Height = 250
            With .Interior
                .ColorIndex = 2
                .PatternColorIndex = 1
                .Pattern = xlSolid
            End With
        End With
        With .ChartTitle
            .Left = 10
            .Top = 5
            .Font.Size = 10
        End With
        With .Axes(xlCategory)
            .MinimumScale = 0
            .MaximumScale = 100
            .MinorUnitIsAuto = True
            .MajorUnitIsAuto = True
        End With
        With .Axes(xlValue)
            .MinimumScale = 0
            .MaximumScale = 100
            .MinorUnitIsAuto = True
            .MajorUnitIsAuto = True
        End With
    End With
    mySht2.Range("A1").Activate
    Set myRng1 = Nothing                '
    Set myRng2 = Nothing
    Set myRng3 = Nothing
    Set mySht1 = Nothing
    Set mySht2 = Nothing
    Set myCht = Nothing
    Set myChtobj = Nothing
End Sub


